home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_218 / edlib / chdir.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  615b  |  37 lines

  1. /*
  2.  * edlib v1.1 Copyright 1989 Edwin Hoogerbeets
  3.  * This code is freely redistributable as long as no charge other than
  4.  * reasonable copying fees are levied for it.
  5.  */
  6. #include "edlib.h"
  7. #include <libraries/dos.h>
  8. #include <errno.h>
  9.  
  10. extern struct FileLock *Lock();
  11. extern struct FileLock *CurrentDir();
  12.  
  13. int chdir(path)
  14. char *path;
  15. {
  16.   struct FileLock *lock;
  17.  
  18.   if ( !path ) {
  19.     errno = EFAULT;
  20.     return(-1);
  21.   }
  22.  
  23.   if ( !isdir(path) ) {
  24.     errno = ENOENT;
  25.     return(-1);
  26.   }
  27.  
  28.   if ( !(lock = Lock(path,ACCESS_READ)) ) {
  29.     errno = EACCES;
  30.     return(-1);
  31.   }
  32.  
  33.   lock = CurrentDir(lock);
  34.  
  35.   return(0);
  36. }
  37.